package kr.hkit.powerjava.chapter22.collection;

import java.util.HashMap;
import java.util.Map;

public class WordFreq {
	public static void main(String[] args) {
		Map<String, Integer> m = new HashMap<String, Integer>();
		
		String[] sample = { "to","be","or","not","to","be","is","a","problem","to"};
		
		for (String a : sample) {
			Integer freq = m.get(a);
			m.put(a,  (freq==null) ? 1 : freq + 1);		//freq가 비어있다면 1, 비어있지 않다면 freq에서 +1
			System.out.println(m.get(a));
		}
		
		System.out.println(m.size() + " 단어가 있습니다. ");
		System.out.println(m.containsKey("to"));
		System.out.println(m.isEmpty());
		System.out.println(m);
	}
}
